﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public sealed class RecruitMoveRequestBLL : IRecruitMoveRequestBLL
    {
        private static readonly IRecruitMoveRequestDAL DAL = DataAccess.CreateRecruitMoveRequest();

        private RecruitMoveRequestInfo reqInfo = new RecruitMoveRequestInfo();
        private EmployeeInfo empInfo = new EmployeeInfo();
        private JobSiteInfo jsInfo = new JobSiteInfo();

        public IList<RecruitMoveRequestInfo> ListMoveRequest()
        {
            return DAL.ListMoveRequest(new RecruitMoveRequestInfo(0));
        }
        public IList<RecruitMoveRequestInfo> ListMoveRequestBySequence(int Sequence)
        {
            return DAL.ListMoveRequest(new RecruitMoveRequestInfo(Sequence));
        }

        public void Insert(string Employee, int SeqNo, string JobSite, Nullable<DateTime> MoveDate, string Reason
            , string Remarks, int CreatedBy)
        {
            if (Employee.Length > 0)
                empInfo.Sequence = Int32.Parse(Employee);
            if (JobSite.Length > 0)
                jsInfo.Sequence = Int32.Parse(JobSite);

            try
            {
                DAL.Insert(new RecruitMoveRequestInfo(0, empInfo, SeqNo, jsInfo, MoveDate, Reason, Remarks, "", CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, int SeqNo, string JobSite, Nullable<DateTime> MoveDate, string Reason
            , string Remarks, int UpdatedBy)
        {
            if (JobSite.Length > 0)
                jsInfo.Sequence = Int32.Parse(JobSite);

            try
            {
                DAL.Update(new RecruitMoveRequestInfo(Sequence, empInfo, SeqNo, jsInfo, MoveDate, Reason, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                DAL.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
